'use strict';


const db = uniCloud.database();
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event',event);

	let tempRes =await db.collection('title').get();
	
	console.log('tempRes',tempRes);
	let nowIndex = 0;
	let tempList = [];
	
	
	while(nowIndex < tempRes['data'].length){
		let countRes = await db.collection('protraitList').where({
			type:tempRes.data[nowIndex]['name']
		}).count();
		let total = countRes['total'];
		console.log(tempRes.data[nowIndex]['name'],':',total);
		if(total >20) tempList.push(tempRes.data[nowIndex]);
		nowIndex++;
	}
	tempRes['data'] = tempList;
	//返回数据给客户端
	return tempRes;
};
